#!/usr/bin/env python3
# coding: utf-8

#!/usr/bin/env python3
#codings: utf-8

import numpy as np
import cv2 as cv
KEY_ESC = 27

def show_color(x):
    print("color",x)

img = np.zeros((500,500,3),np.uint8)
window_name='image'
cv.namedWindow(window_name)
cv.createTrackbar('R',window_name,0,255,show_color)
while True:
    cv.imshow(window_name,img)
    r = cv.getTrackbarPos('R',window_name)
    print("R:",r)
    img[:]=[0,0,r]
    key = cv.waitKey(100) & 0xff
    if key == KEY_ESC:
        break

cv.destroyAllWindows()
